Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds support for host functions to ics23 #90

Merged
merged 3 commits into from
Jun 20, 2022

Conversation

seunlanlege
Copy link
Contributor

This encapsulates all crypto hash functions behind a trait, so downstream crates can delegate these functions to host functions

* adds support for host functions

* cargo fmt

* export HostFunctionsProvider
Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. I agree with the general direction, but request some design changes.

Rather than keep the HostFunctionsManager only in test code (as dev-dependency), I would rather hide it under a feature flag. And ideally have that flag on by default.

For substrate, you can then use no-default-features to avoid this dependency and use the host functions. But it would be a lot less intrusive for other projects (like ibc-rs) that also run in the Hermes relayer and want such functions as well. They should not have to implement this themselves.

use sha2::{Digest, Sha512, Sha512Trunc256};
use sha3::Sha3_512;

pub struct HostFunctionsManager;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, it makes sense to move this.

However, substrate is not the only production user and this code will be needed outside of tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its available in std now

anyhow = { version = "1.0.40", default-features = false }
sp-std = {version = "3.0.0", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.22", default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like tagging to branches here.
Can we just update to a newer release if that is what you need?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, this won't work. Substrate doesn't publish new releases to crates.io so parachain teams need to track git branches for new releases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do they do that? do you know?

Copy link
Contributor Author

@seunlanlege seunlanlege Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the versioning (currently we're at 0.9.24) I'd say they don't want to publish until they hit v1.0.0, which would be considered stable

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethanfrey will you be able to tag a version & publish on crates.io with the dependency specified as git/branch?

* adds support for host functions

* cargo fmt

* export HostFunctionsProvider

* make HostFunctionsManager available in std
Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one last comment for minor updates

rust/src/lib.rs Show resolved Hide resolved
rust/src/ops.rs Show resolved Hide resolved
@ethanfrey
Copy link
Contributor

@hdevalence @adizere @romanc I am pretty sure you all use the std variant here. This change should be compatible, just allow more flexibility at the cost of requiring specifying a hash implementation when calling some functions.

I will likely merge this shortly, but I would really like your feedback before tagging anything, we can still adjust the API to work for all

Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the changes.

I will merge now, but wait feedback from other teams before tagging

@@ -1,5 +1,16 @@
# Changelog

# 0.8.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ethanfrey ethanfrey merged commit 9788227 into cosmos:master Jun 20, 2022
@romanc
Copy link

romanc commented Jun 21, 2022

@hdevalence @adizere @romanc I am pretty sure you all use the std variant here. This change should be compatible, just allow more flexibility at the cost of requiring specifying a hash implementation when calling some functions.

I will likely merge this shortly, but I would really like your feedback before tagging anything, we can still adjust the API to work for all

@ethanfrey I think you tagged me by mistake. I am not part of your project. Just letting you know because it sounded like you wanted feedback from someone else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants